package classification;

import model.Classifier;
import model.Position;
import org.encog.ml.MLRegression;
import org.encog.ml.data.MLData;
import org.encog.ml.data.basic.BasicMLData;
import util.Util;

/**
 * @author Alex Vikharev vikharev@yandex-team.ru
 *         created 28.02.12
 */
public class ClassifierMLRegressionAdapter implements Classifier {
    private final MLRegression regression;

    public ClassifierMLRegressionAdapter(final MLRegression regression) {
        this.regression = regression;
    }

    @Override
    public double classify(final Position move) {
        final MLData compute = regression.compute(new BasicMLData(Util.BITWISE_CONVERTER.apply(Util.getCanonical(move))));
        return compute.getData(0);
    }
}
